<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JsUnit Test Container Controller</title>
    <script language="javascript" type="text/javascript">
        var containerReady = false;

        function init() {
            containerReady = true;
        }

        function isPageLoaded() {
            if (!containerReady)
                return false;

            var isTestPageLoaded = false;

            try {
                // attempt to access the var isTestPageLoaded in the testFrame
                if (typeof(top.testManager.containerTestFrame.isTestPageLoaded) != 'undefined') {
                    isTestPageLoaded = top.testManager.containerTestFrame.isTestPageLoaded;
                }

                // ok, if the above did not throw an exception, then the
                // variable is defined. If the onload has not fired in the
                // testFrame then isTestPageLoaded is still false. Otherwise
                // the testFrame has set it to true
            }
            catch (e) {
                // an error occured while attempting to access the isTestPageLoaded
                // in the testFrame, therefore the testFrame has not loaded yet
                isTestPageLoaded = false;
            }
            return isTestPageLoaded;
        }

        function isContainerReady() {
            return containerReady;
        }

        function setNotReady() {
            try {
                // attempt to set the isTestPageLoaded variable
                // in the test frame to false.
                top.testManager.containerTestFrame.isTestPageLoaded = false;
            }
            catch (e) {
                // testFrame.isTestPageLoaded not available... ignore
            }
        }
        function setTestPage(testPageURI) {
            setNotReady();
            top.jsUnitParseParms(testPageURI);
            testPageURI = appendCacheBusterParameterTo(testPageURI);
            try {
                top.testManager.containerTestFrame.location.href = testPageURI;
            } catch (e) {
            }
        }

        function appendCacheBusterParameterTo(testPageURI) {
            if (testPageURI.indexOf("?") == -1)
                testPageURI += "?";
            else
                testPageURI += "&";
            testPageURI += "cacheBuster=";
            testPageURI += new Date().getTime();
            return testPageURI;
        }
    </script>
</head>

<body onload="init()">
Test Container Controller
</body>
</html>